Purpose: To anchor an image/filter using the landmark points returned by Face Mesh model, to make the
image/filter dynamically follow the face, and switch between multiple filters in real time.
No. of Classes
1 - (Time : 1 hour 30 minutes, Laptops/desktops : 10, Students strength : 15 to 20).
Materials Required
Laptop / Desktop with Internet connections / Wi-Fi, and a webcam on every machine.
Download the accessory images linked in Exercise 1. Images have to be loaded in preload() before
they can be drawn, or nothing will appear on the screen.
Recap the previous lesson: the model returns numbered landmark points, and the numbering is
fixed. A filter stays in place because it is drawn
at
one of those points every time draw() runs, not because it is stuck to the face.
Explain the following to students:
Work through the three decisions involved in placing an accessory - which landmark point
to anchor it to, how wide to draw it, and how far to shift it so that it sits over the
feature rather than beside it.
Ask the students to move closer to and further from the camera. The accessory should
grow and shrink with the face, which means its size has to be worked out from the
landmark points as well, not fixed to one number.
The app has to remember which filter is currently chosen. That is program state - one
variable holds the choice, and a key press or a click changes it.
Draw the accessory after the video, otherwise the webcam picture covers it up.
Discuss some real world applications of the face mesh model.
Points
to Ponder:
Few years ago models like face mesh was research; today it is a phone app anyone uses
without thinking. What is research today that might feel ordinary in ten years?
Every filter you have ever used is built on a model trained by a big company. What
happens to faces, languages or places that those companies did not think about?